﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="inc_ProductImages.ascx.cs" Inherits="AdminPortal_Controls_SanPham_inc_ProductImages" %>
<%@ Register src="../../../Controls/Common/ThumbnailImages.ascx" tagname="ThumbnailImages" tagprefix="uc2" %>
<script>
    $(function () {
        //mouseover line on gird
        $('#ListImage tbody >tr:not(:first)').mouseover(function () {
            $(this).css('background-color', '#fdf3eb');
        });
        $('#ListImage tbody >tr:not(:first)').mouseout(function () {
            $(this).css('background-color', '#fff');
        });
    });
    //xoa anh 
    function DeleteImages(ItemsName,IDimg) {
        var urlDelImg = '<%=Page.ResolveUrl("~/AdminPortal/Controls/SanPham/Ajax/Product_DeleteImage.ashx?id=") %>' + IDimg;
        var target = $('#' + ItemsName).parent().parent();
        
        $.ajax({
            url: urlDelImg,
            success: function (data) {
                var iData = parseInt(data);
                if (iData != -1) {
                    target.hide('slow', function () { target.remove(); });
                }
            }
        });
    }
    //change status
    function changeStatusProductImage(imgName, imgID) {
        var urlUpdateStatus = '<%=Page.ResolveUrl("~/AdminPortal/Controls/SanPham/Ajax/ProductImage_UpdateStatus.ashx?id=") %>' + imgID;
        var img = $('#' + imgName);
        img.fadeOut();
        $.ajax({
            url: urlUpdateStatus,
            success: function (data) {
                if (data == 'true') {
                    img.attr('src', '<%=Page.ResolveUrl("~/AdminPortal/Images/Icon/tree_dnd_yes.png") %>');
                } else {
                    img.attr('src', '<%=Page.ResolveUrl("~/AdminPortal/Images/Icon/tree_dnd_no.png") %>');
                }
            }
        });
        img.fadeIn();
    }

</script>
<div>Đang có <asp:Label ID="lblTotalRecord" runat="server"></asp:Label> hình ảnh</div>
<div id="ListImage">
     <asp:GridView ID="dgvListProductImage" runat="server" 
            AutoGenerateColumns="False" EnableModelValidation="True" GridLines="None" 
            onrowdatabound="dgvListProductImage_RowDataBound">
            <Columns>
                 <asp:TemplateField HeaderText="#" ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="30">
                    <ItemTemplate>
                        <%# Container.DataItemIndex + 1 %>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Hình ảnh"  ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="50">
                    <ItemTemplate>
                        <uc2:ThumbnailImages ID="ThumbnailImages1" runat="server" ThumbNailWidth="35" ThumbNailHeight="30" />
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:TemplateField HeaderText="Đường dẫn">
                    <ItemTemplate>
                        <asp:HyperLink ID="lnkImage" runat="server" Text="link"></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="Trạng Thái" ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="70">
                    <ItemTemplate>
                        <asp:Image ID="imgUpdate" runat="server" style="cursor:pointer;"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Xoá" ItemStyle-CssClass="ItemColumnCenter" HeaderStyle-Width="30">
                    <ItemTemplate>
                        <asp:Image ID="delImg" runat="server" style="cursor:pointer;" ImageUrl="~/AdminPortal/images/icon/remove_16.gif" Width="16" Height="16"/>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
</div>